<template>
  <div class="dashboard-editor-container">
    <github-corner class="github-corner" />
    <el-row :gutter="8">
      <el-col :xs="{span: 24}" :sm="{span: 24}" :md="{span: 24}" :lg="{span: 12}" :xl="{span: 12}" style="padding-right:8px;margin-bottom:30px;">
        <transaction-table />
      </el-col>
      <el-col :xs="{span: 24}" :sm="{span: 12}" :md="{span: 12}" :lg="{span: 6}" :xl="{span: 6}" style="margin-bottom:30px;">
        <todo-list />
      </el-col>
      <el-col :xs="{span: 24}" :sm="{span: 12}" :md="{span: 12}" :lg="{span: 6}" :xl="{span: 6}" style="margin-bottom:30px;">
        <box-card />
      </el-col>
    </el-row>
  </div>
</template>
<script>
import { mapGetters } from 'vuex'
import GithubCorner from '@/components/GithubCorner'
import BoxCard from '@/views/dashboard/admin/components/BoxCard.vue'
import TransactionTable from '@/views/dashboard/editor/components/TransactionTable.vue'
import TodoList from '@/views/dashboard/admin/components/TodoList/index.vue'
import { io } from 'socket.io-client'
import store from '@/store'
import router from '@/router'

export default {
  name: 'DashboardEditor',
  components: {
    TodoList,
    TransactionTable,
    BoxCard,
    GithubCorner
  },

  data() {
    return {
      popupVisible: false,
      popupContent: '这是一个弹窗',
      emptyGif: 'https://wpimg.wallstcn.com/0e03b7da-db9e-4819-ba10-9016ddfdaed3'
    }
  },
  async created() {
    const accessRoutes = await store.dispatch('permission/generateRoutes', sessionStorage.getItem('role'))

    // dynamically add accessible routes
    router.addRoutes(accessRoutes)
  },
  computed: {
    ...mapGetters([
      'name',
      'avatar',
      'roles'
    ])
  },
  mounted() {
    const socket = io.connect('http://1.92.204.101:5000')
    socket.send('connect', sessionStorage.getItem('uid'))
    socket.on('assign', () => {
      console.log(socket.data) // x8WIv7-mJelg7on_ALbx
    })
  },
  methods: {

    showPopup() {
      this.$notify({
        title: 'smyt',
        text: 'Hello user!',
        duration: -1
      })
      this.popupVisible = true
    },
    closePopup() {
      this.popupVisible = false
    }

  }

}
</script>

<style lang="scss" scoped>
.github-corner {
  position: absolute;
  top: 0px;
  border: 0;
  right: 0;
}

  .emptyGif {
    display: block;
    width: 45%;
    margin: 0 auto;
  }

  .dashboard-editor-container {
    background-color: #e3e3e3;
    min-height: 100vh;
    padding: 50px 60px 0px;
    .pan-info-roles {
      font-size: 12px;
      font-weight: 700;
      color: #333;
      display: block;
    }
    .info-container {
      position: relative;
      margin-left: 190px;
      height: 150px;
      line-height: 200px;
      .display_name {
        font-size: 48px;
        line-height: 48px;
        color: #212121;
        position: absolute;
        top: 25px;
      }
    }
  }
</style>
